package com.zcx.ui;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.zcx.R;
import com.zcx.base.BaseActivity;
import com.zcx.bean.PayBean;
import com.zcx.bean.WxPayBean;
import com.zcx.common.DialogHelper;
import com.zcx.common.Helper;
import com.zcx.common.ProgressDialog;
import com.zcx.presenter.PayPresenter;
import com.zcx.view.AlipayView;

import java.util.Map;

public class WxPayActivity extends BaseActivity<AlipayView,PayPresenter> implements AlipayView{

    private ProgressDialog progressDialog;
    private Map<String, String> result;
    private static final String ALI_PAY_SUCCESS = "9000";
    private IWXAPI iwxapi;
    @Override
    protected PayPresenter setPresenter() {
        return new PayPresenter();
    }

    @Override
    protected void onCreateView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_wx_pay);
        findViewById(R.id.btnPay).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getBasePresenter().wxPay();
            }
        });
    }

    @Override
    public void startPay(int resId) {
        progressDialog = DialogHelper.showDialog(this, progressDialog, resId);
    }

    @Override
    public void getPaySucc(PayBean payBean) {

    }

    @Override
    public void getWxPaySucc(WxPayBean payBean) {
        DialogHelper.dismissDialog(progressDialog);
        if (Helper.isNull(payBean)) {
            return;
        }
        // 开始支付
        startWechatPay(payBean);
    }

    private void startWechatPay(WxPayBean payBean) {

    }

    @Override
    public void getPayFail(String message) {
        Toast.makeText(WxPayActivity.this, message, Toast.LENGTH_SHORT).show();
    }

}
